﻿using ConsoleApp.Model.Dto;
using System.Net.Http.Headers;
using System.Net.Http.Json;

namespace ConsoleApp.Service
{
    public class HttpHelper<T> 
    {



        public static async Task<string> DoPost(string Url, HttpHeader header,T param)
        {
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("ContentType",header.ContentType);
            client.DefaultRequestHeaders.Add("UserAgent", header.UserAgent);
            client.DefaultRequestHeaders.Add("Sign", header.Sign);
            client.DefaultRequestHeaders.Add("roleKey", header.RoleKey);
            client.DefaultRequestHeaders.Add("Host", header.Host);

            client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", header.Authorization);

            var res = await client.PostAsJsonAsync(Url, param);

            return await res.Content.ReadAsStringAsync();
        }


    }
}
